<?php
include "vhod.php";

	$login=$_POST["login"]; 
	$pass=$_POST["pass"];
	
	 if(isset($_POST['submit'])) 
	{ 
	  $db = new DB();   
	  $data=$db->find('user','id,password','login',$login) ;
	     
	  if($data[0]['password'] === md5($pass))
	  {
	  	$hash = md5($db->generateCode(10)); 
	  	$ha=array("hash"=>$hash);
	  	$db->update('user',$ha,'login',$login);
	  	setcookie("id", $data[0]['id'], time()+60*60*24*30); 
	    setcookie("hash", $hash, time()+60*60*24*30); 
	    header("Location: cook.php"); exit(); 
	  	
	  }
	  else echo ("Неправильно введен логин/пароль");
	}
?>

<form action="autoriz.php" method="post" name="frt" >
Логин <input name="login" type="text"><br> 
Пароль <input name="pass" type="password"><br> 
<input name="submit" type="submit" value="Войти"> 
</form> 
